<?php
/* SVN FILE: $Id: assessment_test_case.php 16 2009-09-27 01:48:47Z kenreily@gmail.com $ */
/**
 * Short description for file.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * Recenseo: Online submission and reviewing for education
 * Copyright 2008-2009, Ken Reily
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * $Date: 2009-09-27 01:48:47 +0000 (Sun, 27 Sep 2009) $
 * $Revision: 16 $
 * $Author: kenreily@gmail.com $
 * $HeadURL: http://recenseo.googlecode.com/svn/trunk/app/models/assessment_test_case.php $
 */
class AssessmentTestCase extends AppModel {
  var $name = 'AssessmentTestCase';
  var $belongsTo = array('Assessment','TestCaseResult','TestCase');
  var $validate = array(
    'results' => array(
		       'rule' => array('minLength',1)),

    'test_case_result_id' => array(
      'rule' => 'numeric',
      'allowEmpty' =>false,
      'required' => true,
      'message' => 'Please choose the result that most closely describes the outcome of executing your test.'));
  
  function getForAssessment($assessment_id)
  {
    return $this->query("SELECT at.id,t.id,t.name,t.description,at.results,r.name " .
                        "FROM assessment_test_cases at " .
                        "JOIN test_cases t on t.id = at.test_case_id " .
                        "JOIN test_case_results r on r.id = at.test_case_result_id " .
                        "WHERE assessment_id = {$assessment_id} ORDER BY at.id");
  }
}
?>